FROM node:12-alpine as builder

RUN npm i tyarn -g && tyarn global add umi

# install and cache app dependencies
COPY package.json ./app/
WORKDIR /app

RUN tyarn install

COPY src/ ./src
COPY .umirc.js jsconfig.json webpack.config.js ./

RUN tyarn build

# ------------------------------------------------------
# Production Build
# ------------------------------------------------------
FROM nginx:1.19-alpine
COPY --from=builder /app/dist /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx_app.conf /etc/nginx/conf.d
COPY start.sh /app/
CMD ["sh", "/app/start.sh"]
